<!--
新闻中心列表
 add by yyp 2019-05-10
-->
<template lang="pug">
  keep-alive
    kalix-table(bizKey="News" title='新闻中心列表' ref="kalixTable"
    v-bind:tableFields="tableFields"
    v-bind:targetURL="NewsURL"
    v-bind:bizDialog="newsDialog"
    v-bind:btnList="newsBtnList"
    v-bind:toolbarBtnList="toolbarBtnList"
    bizSearch="newsSearch")
      template(slot="tableColumnSlot")
        el-table-column(prop="newTitle" label="新闻标题" align="center")
        el-table-column(prop="id" label="ID" align="center")
        el-table-column(prop="newDate" label="新闻日期" align="center")
          template(slot-scope="scope")
            span {{dataFormat(scope.row.newDate)}}
        <!--el-table-column(prop="newUrl" label="新闻图片" align="center")-->
        el-table-column(prop="newUrl" label="新闻图片")
          template(slot-scope="scope")
            <!--img(:src="scope.row.newUrl" width="100px" readonly="readonly")-->
            div(v-for="img in getArray(scope.row.newUrl)")
              img(v-bind:src="img" width="60" height="60" alt="" style="float:left; margin-right: 8px")
        el-table-column(prop="newDetails" label="新闻详情" align="center")
        el-table-column(prop="newOrder" label="新闻排序" align="center")
</template>

<script type="text/ecmascript-6">
  import {NewsURL} from '../../config.toml'
  import {newsConfigBtnList} from './config'
  import KalixTable from '../../../../../components/corelib/components/common/baseTable'

  export default {
    name: 'kalix-mooc-news',
    components: {KalixTable},
    data() {
      return {
        NewsURL: NewsURL,
        tableFields: [
          {prop: 'newTitle', label: '新闻标题'},
          {prop: 'newDate', label: '新闻日期'},
          {prop: 'newUrl', label: '新闻图片'},
          {prop: 'newDetails', label: '新闻详情'},
          {prop: 'newOrder', label: '新闻排序'}
        ],
        newsDialog: [
          {id: 'add', dialog: 'newsAdd'},
          {id: 'edit', dialog: 'newsEdit'},
          {id: 'view', dialog: 'newsView'}
        ],
        newsBtnList: newsConfigBtnList,
        toolbarBtnList: [
          {id: 'add', isShow: true, title: '添加', icon: 'icon-pinleizengjia', isPermission: true}
        ]
      }
    },
    methods: {
      getArray(val) {
        return val.split(',')
      },
      dataFormat(val) {
        let d = new Date(val)
        return this.$M_FormatDate(d, 'yyyy-MM-dd')
      }
    }
  }
</script>

<style scoped lang="stylus">

</style>
